有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何强制Eclipse链接创建完全相同类名的表?

我希望JPA EclipseLink创建的表与类名(和字段)完全相同,没有注释@Table和@Column。它总是创建大写的表和字段,这使得DB控制台的可读性很难

例:

@Entity
public class ChannelEntity {
    
    @Id     @GeneratedValue  
    public Long id;
    
    public String name;
    
    public String description;
    
    public Boolean oficial;

    @Temporal(TemporalType.TIMESTAMP)
    public Date creation;

}

我想知道结果

    Table: ChannelEntity
    id  creation    description name        oficial
   ----------------------------------------------------
    351 NULL        meu desc    meu nome    1

持久化中可能存在相同的参数。xml,但我找不到它


共 (1) 个答案

  1. # 1 楼答案

    如果EclipseLink的行为正确,那么您要查找的参数是delimited-identifers。来自JPA 2.1规范:

    It is possible to specify that all database identifiers in use for a persistence unit be treated as delimited identifiers by specifying the <delimited-identifiers/> element within the persistence-unit-defaults element of the object/relational xml mapping file. If the <delimited-identifiers/> element is specified, it cannot be overridden.

    如果包含这个元素,EclipseLink应该在其生成的SQL中定义所有数据库标识符,这将导致使用区分大小写的名称创建数据库对象